﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace Compact13TaskManager
{
     public partial class frmMain : Form
    {
        public delegate void DelegateClearListBox1();
        private void ClearListBox1()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DelegateClearListBox1(ClearListBox1));
                return;
            }
            listBox1.Items.Clear();
            listBox1.Items.Add(string.Format(" {0,-" + WindowDetail.WindowTextLength.ToString() + "}  {1,-8}", "App.", "Win Handle"));
        }

        public delegate void DelegateAddListBox1Item(string txt);
        private void AddListBox1Item(string txt)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DelegateAddListBox1Item(AddListBox1Item));
                return;
            }
            listBox1.Items.Add(txt);
        }

        public delegate void DelegatSetListBox1ItemIndex(int Index);
        private void SetListBox1ItemIndex(int Index)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new DelegatSetListBox1ItemIndex(SetListBox1ItemIndex));
                return;
            }
            WindowListCurrentIndex = Index;
            listBox1.SelectedIndex = Index;
        }
    }
}
